﻿//Bottom-Right

//var x = gameobject.Rectangle.X + gameobject.Rectangle.Width;
//var y = gameobject.Rectangle.Y + gameobject.Rectangle.Height;

//var gridX = (int)Math.Floor(x / TileWidth);
//var gridY = (int)Math.Floor(y / TileWidth);
//if (gridX >= 0 && gridY >= 0 && gridX < GridLength && gridY < GridHeight)
//{
//    if (Grid[gridX, gridY] != null)
//    {
//        gameobject.X = Grid[gridX, gridY].Rectangle.Left - gameobject.Width - 1;
//        gameobject.Y = Grid[gridX, gridY].Rectangle.Top - gameobject.Height - 1;
//        return true;
//    }
//}
//else
//    return true;
////BottomLeft
//x = gameobject.Rectangle.X;
//y = gameobject.Rectangle.Y + gameobject.Rectangle.Height;

//gridX = (int)Math.Floor(x / TileWidth);
//gridY = (int)Math.Floor(y / TileWidth);
//if (gridX >= 0 && gridY >= 0 && gridX < GridLength && gridY < GridHeight)
//{
//    if (Grid[gridX, gridY] != null)
//    {
//        gameobject.X = Grid[gridX, gridY].Rectangle.Right - 1;
//        gameobject.Y = Grid[gridX, gridY].Rectangle.Top - gameobject.Height - 1;
//        return true;
//    }
//}
//else
//    return true;
////Top-Left
//x = gameobject.Rectangle.X;
//y = gameobject.Rectangle.Y;

//gridX = (int)Math.Floor(x / TileWidth);
//gridY = (int)Math.Floor(y / TileWidth);
//if (gridX >= 0 && gridY >= 0 && gridX < GridLength && gridY < GridHeight)
//{
//    if (Grid[gridX, gridY] != null)
//    {
//        gameobject.X = Grid[gridX, gridY].Rectangle.Right - 1;
//        gameobject.Y = Grid[gridX, gridY].Rectangle.Bottom - 1;
//        return true;
//    }
//}
//else
//    return true;

////Top-Right
//x = gameobject.Rectangle.X + gameobject.Rectangle.Width;
//y = gameobject.Rectangle.Y;

//gridX = (int)Math.Floor(x / TileWidth);
//gridY = (int)Math.Floor(y / TileWidth);
//if (gridX >= 0 && gridY >= 0 && gridX < GridLength && gridY < GridHeight)
//{
//    if (Grid[gridX, gridY] != null)
//    {
//        gameobject.X = Grid[gridX, gridY].Rectangle.Left - gameobject.Width - 1;
//        gameobject.Y = Grid[gridX, gridY].Rectangle.Bottom - 1;
//        return true;
//    }
//}
//else
//    return true;

//return false;



//bool intersect = false;
//for (int y = 0; y < Grid.GetLength(1); y++)
//{
//    for (int x = 0; x < Grid.GetLength(0); x++)
//    {
//        if (Grid[x, y] != null)
//        {
//            if (Grid[x, y].SolidState == SolidState.Solid)
//            {
//                if (gameobject.Rectangle.Intersects(Grid[x, y].Rectangle))
//                {
//                    Grid[x, y].IsIntersected = true;
//                    return true;
//                }
//                else
//                {
//                    Grid[x, y].IsIntersected = false;
//                }
//            }
//        }
//    }
//}
//return intersect;